package com.hxkcloud.patient.activitys;

import android.content.Intent;
import android.os.Bundle;
import android.os.Message;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.hxkcloud.patient.R;

/**
 * Created by ray_lei on 2016/7/6.
 */
public class TitleForDNActivity extends BaseActivity implements View.OnClickListener {

    private LinearLayout titleLayout;
    private TextView titleTV;//标题
    private ImageView backIV;//回退按钮
    private TextView rightTV;//保存按钮

    private EditText titleET;

    private String name;

    @Override
    protected void updateByHandler(Message msg) {
        switch (msg.what) {

        }
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_layout_titlefordn);

        name = this.getIntent().getStringExtra("name");
        initView();
        initData();
        initListener();
    }

    @Override
    protected void initView() {

        titleLayout = (LinearLayout) findViewById(R.id.ll_title);
        setTitlePadding(titleLayout);

        titleTV = (TextView) findViewById(R.id.tv_title_title);
        titleTV.setText(getResources().getString(R.string.personalinfofordn_text_title));
        backIV = (ImageView) findViewById(R.id.iv_title_back);
        backIV.setVisibility(View.VISIBLE);
        rightTV = (TextView) findViewById(R.id.tv_title_func);
        rightTV.setVisibility(View.VISIBLE);
        rightTV.setText(getResources().getString(R.string.departmentfordn_save));

        titleET = (EditText) findViewById(R.id.titlefordn_et_title);

        titleET.setText(name);
    }

    @Override
    protected void initListener() {

        backIV.setOnClickListener(this);
        rightTV.setOnClickListener(this);
    }

    @Override
    protected void initData() {

    }

    @Override
    public void onClick(View v) {

        switch (v.getId()) {
            case R.id.iv_title_back:
                finish();
                break;

            case R.id.tv_title_func:
                if (titleET.getText().toString().trim() != null) {
                    Intent intent = new Intent();
                    intent.putExtra("title", titleET.getText().toString().trim());
                    setResult(1, intent);
                    finish();
                }
                break;
        }

    }
}
